package com.neusoft.elmboot.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.neusoft.elmboot.po.WalletRules;
import com.neusoft.elmboot.service.WalletRulesService;

@RestController
@RequestMapping("/WalletRules")
public class WalletRulesController {

	@Autowired
	private WalletRulesService walletRulesService;
	
	@PostMapping("/type/{type}/everpay/{everpay}/give/{give}/discount/{discount}/interest/{interest}")
	public int saveRule(WalletRules walletRules) throws Exception{
		return walletRulesService.saveRule(walletRules);
	}
	
	@PutMapping("/everpay/{everpay}/give/{give}/discount/{discount}/interest/{interest}/type/{type}")
	public int changeRule(WalletRules walletRules) throws Exception{
		return walletRulesService.changeRule(walletRules);
	}
	
	@GetMapping("/type/{type}")
	public WalletRules getRulesBytype(WalletRules walletRules) throws Exception{
		return walletRulesService.getRulesBytype(walletRules.getType());
	}
}